import 'zone.js/dist/zone-node'
import 'reflect-metadata'

import { enableProdMode } from '@angular/core'
enableProdMode()
import { main } from './framework'
import { ApplicationModule } from './app.module'
import { InstallModule } from './install'
import * as cluster from 'cluster'
import * as os from 'os'
const numCPUs = os.cpus().length
;(global as any).MEEPO_ROOT = __dirname
if (cluster.isMaster) {
  console.log(`主进程 ${process.pid} 正在运行`)
  // 衍生工作进程。
  for (let i = 0; i < numCPUs; i++) {
    cluster.fork()
  }
  cluster.on('exit', (worker, code, signal) => {
    console.log(`工作进程 ${worker.process.pid} 已退出`)
  })
} else {
  main({
    base: __dirname,
    port: 3005,
    host: '0.0.0.0',
    app: ApplicationModule,
    install: InstallModule
  }).subscribe()
}
